﻿
using System.Collections.Generic;
namespace MvcApplication.Entity
{
    public class PaginationResult<T> : Pager where T : class
    {
        public PaginationResult(Pager pager)
        {
            base.PageSize = pager.PageSize;
            base.PageIndex = pager.PageIndex;
        }

        public PaginationResult(Pager pager, List<T> datas, int dataCount)
        {
            base.PageSize = pager.PageSize;
            base.PageIndex = pager.PageIndex;

            DataCount = dataCount;
            Datas = datas;
        }

        public int DataCount { get; set; }

        public List<T> Datas { get; set; }

        public int PageCount
        {
            get
            {
                var page = DataCount / PageSize;
                if (DataCount % PageSize > 0) page++;

                return page;
            }
        }

        public bool HasNext
        {
            get
            {
                return PageCount > PageSize;
            }
        }

        public bool HasPrev
        {
            get
            {
                return PageIndex > 1;
            }
        }
    }
}
